package com.softeem.oss_music.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.softeem.oss_music.comm.R;
import com.softeem.oss_music.entity.Album;
import com.softeem.oss_music.entity.Music;
import com.softeem.oss_music.mapper.AlbumMapper;
import com.softeem.oss_music.service.MusicService;
import com.softeem.oss_music.mapper.MusicMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
* @author 来吾告汝
* @description 针对表【music】的数据库操作Service实现
* @createDate 2025-10-28 11:48:42
*/
@Service
public class MusicServiceImpl extends ServiceImpl<MusicMapper, Music>
    implements MusicService{

    @Autowired
    private AlbumMapper albumMapper;

    @Override
    public R musicDetails(Integer id) {
        //根据id查询音乐
        Music m = getById( id);
        if (m == null){
            return R.error().setMessage("音乐不存在");
        }
        if (m.getAid() ==  null){
            return R.error().setMessage("专辑不存在");
        }
        //根据专辑id查询专辑信息
        Album a = albumMapper.selectById(m.getAid());

        m.setAlbum(a);
        return R.success().setData(m);
    }
}




